﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using Cofco.login;

namespace POS
{
    public partial class Login : DevExpress.XtraEditors.XtraForm
    {
        frmLogin form = null;
        public Login()
        {
            InitializeComponent();
        }

        private void Login_Load(object sender, EventArgs e)
        {
            AddLogin(sender, e);
            notifyIcon.Text = "兴富长荣POS系统";
        }

        void AddLogin(object sender, EventArgs e)
        {
            this.panel.Controls.Clear();
            form = new frmLogin();
            form.TopLevel = false;
            form.Dock = DockStyle.Fill;
            this.panel.Controls.Add(form); 
            form.LoginRightMenuUC.MenuSeting.Click += new EventHandler(Seting_Click);
            form.LoginRightMenuUC.MenuMini.Click += new EventHandler(MenuMini_Click);
            form.Show();
        }

        void Seting_Click(object sender, EventArgs e)
        {
            this.panel.Controls.Clear();
            frmLoginSetting form = new frmLoginSetting();
            form.TopLevel = false;
            form.Dock = DockStyle.Fill;
            this.panel.Controls.Add(form);
            form.Show();
        }

        void MenuMini_Click(object sender, EventArgs e)
        {
            if (this.WindowState != FormWindowState.Minimized)
            {
                this.WindowState = FormWindowState.Minimized;
                this.ShowInTaskbar = false;
                notifyIcon.Visible = true;
            }
        }

        private void notifyIcon_DoubleClick(object sender, EventArgs e)
        {
            form.frmmain.Visible = true;
            form.frmmain.Show();
            form.frmmain.Focus();
            //if (this.WindowState == FormWindowState.Minimized)
            //{
            //    this.ShowInTaskbar = true;
            //    this.WindowState = FormWindowState.Normal;
            //    notifyIcon.Visible = false;
            //}
        }

        private void KillProcess_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }
    }
}